/*************************************************************************
	> File Name: P1200.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-07-09 17:18:39
 ************************************************************************/

#include <iostream>
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int x = 1, y = 1;
    for (int i = 0; i < a.size(); i++) {
        x *= (a[i] - 'A' + 1);
    }
    for (int i = 0; i < b.size(); i++) {
        y *= (b[i] - 'A' + 1);
    }
    bool flag = (x % 47 == y % 47);
    cout << (flag ? "GO" : "STAY") << endl;
    return 0;
}
